import Vue from "vue"

import VueRouter from "vue-router"

const Home = () => import("../pages/Home")
const Login = () => import("../pages/Login")
const Music = () => import("../pages/Home/Music")
const News = () => import("../pages/Home/News")
const Games = () => import("../pages/Home/Games")
const Movie = () => import("../pages/Home/Movie")

Vue.use(VueRouter)

export default new VueRouter({
  mode: "history",
  routes: [
    {
      path: "/login",
      component: Login,
      name: "login"
    },
    {
      path: "/home",
      component: Home,
      children: [
        {
          path: "music/:id/:time?",
          component: Music,
          name: "music",
          props: true
        },
        {
          path: "news",
          component: News,
          name: "news"
        },
        {
          path: "movie",
          component: Movie,
          name: "movie",
          props: (route) => {
            return { ...route.query, ...route.params }
          }
        },
        {
          path: "game",
          component: Games,
          name: "game",
          props: (route) => {
            return { ...route.query, ...route.meta }
          },
          meta: {
            gameName: "黑暗之魂3",
          }
        },
        {
          path: "",
          redirect: "/home/news"
        },
      ]
    },
    { path: "/", redirect: "/home" },
  ]
})